package com.tuni.birthdaymoney.persistence.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Type;
import org.joda.time.LocalTime;

// TODO: Not finished. Not tested yet.
@Entity
@Table(name = "BM_Settings")
public class NotificationSettings implements Serializable {
    private Integer id;
    private Integer notificationPeriod;
    private LocalTime notificationTime;
    private String smtpServerAddress;
    private String smtpUsername;
    private String smtpPassword;

    /*public void copyFrom(NotificationSettings source) {
        setNotificationPeriod(source.getNotificationPeriod());
        setNotificationTime(source.getNotificationTime());
        setSmtpServerAddress(source.getSmtpServerAddress());
        setSmtpUsername(source.getSmtpUsername());
        setSmtpPassword(source.getSmtpPassword());
    }*/

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "NotificationTime", nullable = false)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalTime")
    public LocalTime getNotificationTime() {
        // DateTimeZone arg0 = DateTimeZone.forOffsetHours(+4);
        // System.out.println("Notification time is (org): " + notificationTime);
        // System.out.println("Notification time is (mod): " + notificationTime.toDateTimeToday(arg0));
        return notificationTime;
    }

    public void setNotificationTime(LocalTime notificationTime) {
        this.notificationTime = notificationTime;
    }

    @Column(name = "NotificationPeriod", nullable = false)
    public Integer getNotificationPeriod() {
        return notificationPeriod;
    }

    public void setNotificationPeriod(Integer notificationPeriod) {
        this.notificationPeriod = notificationPeriod;
    }

    @Column(name = "smtpServerAddress", nullable = false, length = 40)
    public String getSmtpServerAddress() {
        return smtpServerAddress;
    }

    public void setSmtpServerAddress(String smtpServerAddress) {
        this.smtpServerAddress = smtpServerAddress;
    }

    @Column(name = "smtpUsername", nullable = false, length = 40)
    public String getSmtpUsername() {
        return smtpUsername;
    }

    public void setSmtpUsername(String smtpUsername) {
        this.smtpUsername = smtpUsername;
    }

    @Column(name = "smtpPassword", nullable = false, length = 40)
    public String getSmtpPassword() {
        return smtpPassword;
    }

    public void setSmtpPassword(String smtpPassword) {
        this.smtpPassword = smtpPassword;
    }
}
